// miniprogram/pages/history/history.js
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    history:[
        [
          {a:1},
          {a:11}
        ],
        [{a:2}]
      ],
      color:[
        "bg-red",
        "bg-orange",
        "bg-blue",
        "bg-green",
        "bg-olive",
        "bg-cyan",
        "bg-yellow",
        "bg-purple",
        "bg-mauve",
        "bg-grey",
        "bg-brown",
        "bg-gray",
        "bg-black"
      ],
      random:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    this.setData({
      history:app.globalData.history
    });
    this.getRandom()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  // 获取颜色随机数
  getRandom(){
    var num = []
    for(var i=0; i<this.data.history.length; i++){
      num[i] = parseInt(Math.random()*12)
    }
    // console.log(num)
    this.setData({
      random:num
    })
    //console.log(this.data.random)
  }
})
